/**
 * $Id$
 * @author mcanovas
 * @date   Mar 7, 2012 9:14:01 AM
 *
 * Copyright (C) 2012 Scytl Secure Electronic Voting SA
 *
 * All rights reserved.
 *
 */
package org.sk.gsync.app.mybatis;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

public class QueueService {

    @Autowired
    private QueueMapper queueMapper;

    public QueueItem next() {
        return queueMapper.findFirst();
    }

    @Transactional
    public void storeItems(final List<QueueItem> items) {
        for (QueueItem queueItem : items) {
            queueMapper.insert(queueItem);
        }
    }

    @Transactional
    public void removeItems(final List<QueueItem> items) {
        for (QueueItem queueItem : items) {
            queueMapper.delete(queueItem);
        }
    }

    @Transactional
    public void updateItems(final List<QueueItem> items) {
        for (QueueItem queueItem : items) {
            queueMapper.update(queueItem);
        }
    }

}
